package design.pattern.ChainOfResponsibility.main;

import design.pattern.ChainOfResponsibility.iner.impl.DefaultImplProcessor;
import design.pattern.ChainOfResponsibility.instance.AddRequestHeaderProcessor;
import design.pattern.ChainOfResponsibility.instance.AddResponseHeaderProcessor;
import design.pattern.ChainOfResponsibility.instance.LoggerProcessor;

public class ChainOfResponsibilityMain {
  public static void main(String[] args) {
    // 构建实例
    LoggerProcessor loggerProcessor = new LoggerProcessor();
    AddRequestHeaderProcessor addRequestHeaderProcessor = new AddRequestHeaderProcessor();
    AddResponseHeaderProcessor addResponseHeaderProcessor = new AddResponseHeaderProcessor();
    
    // 构建 impl 实现类
    DefaultImplProcessor defaultImplProcessor = new DefaultImplProcessor();
    // 构建链表
    defaultImplProcessor.addLast(addRequestHeaderProcessor)
        .addLast(loggerProcessor)
        .addLast(addResponseHeaderProcessor);
    
    // 所以开始执行
    defaultImplProcessor.getFirst().entry();
  }
}
